﻿' Copyright (C) 2011  Jan-Willem de Bruyn
'
'    This program is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 3 of the License, or
'    (at your option) any later version.
'
'    This program is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.
'
'    You should have received a copy of the GNU General Public License
'    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Imports System.IO
Imports System.Net

Public Class rssmaker
    Inherits System.Web.UI.Page
    Dim mywebclient As New WebClient()
    Dim pagehtmlbytes() As Byte
    Dim outf8 As UTF8Encoding = New UTF8Encoding()
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox2.TextChanged

    End Sub

    Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox1.TextChanged

    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        TextBox4.Text = "<item>" & vbCrLf & _
            "<title>" & TextBox1.Text & "</title>" & vbCrLf & _
            "<description>" & TextBox2.Text & "</description>" & vbCrLf & _
            "<link>" & TextBox3.Text & "</link>" & vbCrLf & _
            "<pubDate>" & TextBox5.Text & "</pubDate>" & vbCrLf & _
            "</item>"

    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
        Dim rss As String = "<?xml version=""1.0"" encoding=""ISO-8859-1"" ?>" & vbCrLf & _
            "<!-- Feed created by the Psyonity-inc Online Feed Generator. -->" & vbCrLf & _
            "<rss version=""2.0"">" & vbCrLf & _
            "<channel>" & vbCrLf & _
            "<title>" & TextBox7.Text & "</title>" & vbCrLf & _
            "<link>" & TextBox8.Text & "</link>" & vbCrLf & _
            "<description>" & TextBox9.Text & "</description>" & vbCrLf & _
            "<language>" & TextBox10.Text & "</language>" & vbCrLf & _
            "<copyright>" & TextBox11.Text & " made by Psyonity-inc rss generator" & "</copyright>" & vbCrLf & _
            "<generator>" & "Psyonity-inc Feed Generator FREE Version 1.03 " & "</generator>" & vbCrLf & _
            TextBox4.Text & vbCrLf & _
            "</channel>" & vbCrLf & _
            "</rss>"
        Dim readobj As New StreamReader(FileUpload1.PostedFile.InputStream)
        Response.ContentType = "text/xml"
        Response.AddHeader("Content-disposition", "attachment; filename=" & "rss.xml")
        Dim input As String = readobj.ReadToEnd()

        If input = "" Then
            Response.Write(rss)
            Response.End()
        Else
            Response.Write(input.Insert(input.IndexOf("<item>"), TextBox4.Text))
            Response.End()
        End If
    End Sub

    Protected Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox3.TextChanged

    End Sub
End Class